package cn.smbms.service;

import cn.smbms.dao.BillMapper;
import cn.smbms.pojo.Bill;
import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@Service
public class BillServiceImpl implements BillService {

    @Resource
    private BillMapper billMapper;


    @Override
    public List<Bill> getByProduct(String productName,
                                   Integer providerId,
                                   Integer isPayment,
                                   Integer PageNo,
                                   Integer pageSize) {
        Integer currentPageNo = (PageNo-1)*pageSize;
        return billMapper.getByProduct(productName,providerId,isPayment,currentPageNo,pageSize);
    }

    @Override
    public Integer getBillCount(String productName,
                                Integer providerId,
                                Integer isPayment) {
        return billMapper.getBillCount(productName,providerId,isPayment);
    }

    @Override
    public Bill getBillById(Integer id) {
        return billMapper.getBillById(id);
    }

    @Override
    public boolean delete(Integer id) {
        return billMapper.delete(id)>0?true:false;
    }

    @Override
    public boolean modify(Bill bill) {
        return billMapper.modify(bill)>0?true:false;
    }

    @Override
    public boolean add(Bill bill) {
        return billMapper.add(bill)>0?true:false;
    }

    @Override
    public Integer count(Integer id) {
        return billMapper.count(id);
    }


}
